package org.softmed.rest.server.core.restlet;

import org.restlet.Context;
import org.restlet.Restlet;
import org.restlet.data.Request;
import org.restlet.data.Response;
import org.softmed.rest.config.Application;
import org.softmed.rest.config.Module;
import org.softmed.rest.config.Resource;

public class RESTConfiguredRestlet extends Restlet {

	Application application;
	Module module;
	Resource resource;

	Context context;

	@Override
	public void handle(Request request, Response response) {
		// TODO change this for a cloned resource set
		// System.out.println("resource - "
		// + request.getResourceRef().getBaseRef());
		// System.out.println("relative path - "
		// + request.getResourceRef().getPath());

		new ResourceHandler(application, module, resource, context, request,
				response);

		// test
		if (response.isEntityAvailable()) {
			System.out.println("COOL");
			response.setLocationRef(request.getResourceRef());
		} else
			System.out.println("NOT COOL");
	}

	public Resource getResource() {
		return resource;
	}

	public void setResource(Resource resource) {
		this.resource = resource;
	}

	public Application getTabulaApplication() {
		return application;
	}

	public void setApplication(Application application) {
		this.application = application;
	}

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public Context getContext() {
		return context;
	}

	public void setContext(Context context) {
		this.context = context;
	}

}
